# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd

def group_by(idx):
    return len(idx)
if __name__ == '__main__':
    frame = pd.DataFrame(np.random.randint(1, 10, (5, 5)), columns=['a', 'b', 'c', 'd', 'e'],
                         index=['AA', 'BBB', 'CC', 'D', 'EE'])
    print frame
    print frame.groupby(group_by).size()